using UnityEngine;

namespace FShaderInspector
{
    /// <summary> GUIStyle 拓展 </summary>
    public static class GUIStyleExtension
    {
        /// <summary> 设置适应拉伸自宽度 </summary>
        /// <param name="style">this</param> <param name="enable">启用</param> <returns>this</returns>
        public static GUIStyle SetStretchWidth(this GUIStyle style, bool enable)
        {
            style.stretchWidth = enable;
            return style;
        }

        /// <summary> 设置适应拉伸自高度 </summary>
        /// <param name="style">this</param> <param name="enable">启用</param> <returns>this</returns>
        public static GUIStyle SetStretchHeight(this GUIStyle style, bool enable)
        {
            style.stretchHeight = enable;
            return style;
        }

        /// <summary> 设置固定高度 </summary>
        /// <param name="style">this</param> <param name="fixedHeight">固定高度</param> <returns>this</returns>
        public static GUIStyle SetFixedHeight(this GUIStyle style, int fixedHeight)
        {
            style.fixedHeight = fixedHeight;
            return style;
        }

        /// <summary> 设置对齐方式 </summary>
        /// <param name="style">this</param> <param name="alignment">TextAnchor 对齐枚举</param> <returns>this</returns>
        public static GUIStyle SetAlignment(this GUIStyle style, TextAnchor alignment)
        {
            style.alignment = alignment;
            return style;
        }

        /// <summary> 设置字体大小 </summary>
        /// <param name="style">this</param> <param name="size">字体大小</param> <returns>this</returns>
        public static GUIStyle SetFontSize(this GUIStyle style, int size)
        {
            style.fontSize = size;
            return style;
        }

        /// <summary> 设置内容偏移 </summary>
        /// <param name="style">this</param> <param name="offset">内容偏移</param> <returns>this</returns>
        public static GUIStyle SetContentOffset(this GUIStyle style, Vector2 offset)
        {
            style.contentOffset = offset;
            return style;
        }

        /// <summary> 设置边距 </summary>
        /// <param name="style">this</param> <param name="offset">矩形偏移量</param> <returns>this</returns>
        public static GUIStyle SetMargin(this GUIStyle style, RectOffset offset)
        {
            style.margin = offset;
            return style;
        }

        /// <summary> 设置填充 </summary>
        /// <param name="style">this</param> <param name="rectOffset">矩形偏移量</param> <returns>this</returns>
        public static GUIStyle SetPadding(this GUIStyle style, RectOffset rectOffset)
        {
            style.padding = rectOffset;
            return style;
        }

        /// <summary> 设置渲染内容裁剪模式 </summary>
        /// <param name="style">this</param> <param name="clipping">文本裁剪</param> <returns>this</returns>
        public static GUIStyle SetClipping(this GUIStyle style, TextClipping clipping)
        {
            style.clipping = clipping;
            return style;
        }
    }
}